/**************************************************************************
* This file is part of Hawkengine.
*
* Hawkengine is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hawkengine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Hawkengine.  If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/

#ifndef _BOUNDS_H_
#define _BOUNDS_H_

/**************************************************************************
* Dependencies
**************************************************************************/
#include "engine/common.h"
 
/**************************************************************************
* Preprocessing
**************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif

/**************************************************************************
* Types
**************************************************************************/
typedef struct
{
  float left;
  float right;
  float bottom;
  float top;
} bounds_type;

/**************************************************************************
* Variables
**************************************************************************/
extern const bounds_type UNIT_BOUNDS;

/**************************************************************************
* Static Variables
**************************************************************************/

/**************************************************************************
* Function Prototypes
**************************************************************************/
float bounds_aspect(const bounds_type* bounds);
void bounds_center(const bounds_type* bounds, float* x_center, float* y_center);
float bounds_center_x(const bounds_type* bounds);
float bounds_center_y(const bounds_type* bounds);
BOOL bounds_contain(const bounds_type* bounds, float x, float y);
void bounds_convert_xy(const bounds_type* old_bounds,
                       const bounds_type* new_bounds,
                       float* x, float* y);
void bounds_convert_xy_scale(const bounds_type* old_bounds,
                             const bounds_type* new_bounds,
                             float* x, float* y);
BOOL bounds_equal(const bounds_type* bounds1, const bounds_type* bounds2);
float bounds_height(const bounds_type* bounds);
void bounds_keep_aspect(const bounds_type* target_bounds, bounds_type* bounds);
void bounds_shrink(bounds_type* bounds, float percent);
void bounds_slide(bounds_type* bounds, float delta_x, float delta_y);
void bounds_trim_to_aspect(const bounds_type* target_bounds, bounds_type* bounds);
float bounds_width(const bounds_type* bounds);

/**************************************************************************
* Function Implementations
**************************************************************************/


#ifdef __cplusplus
}
#endif

#endif
